<template lang="pug">
  .formInfoBox
    el-row
      el-col(:span="24 - rightSpan")
        el-row
          el-col(v-for="item in list" :key="item.key" v-bind="item.layoutCol || layoutCol")
            .formItem
              .title(:style="{width: item.width || '120px'}")
                i.c_error(v-if="item.required") *
                span {{item.label}}
              .content
                span(v-if="item.initialValue" :title="item.initialValue") {{item.initName || item.initialValue}}
                slot(v-else :slot="item.key")
      el-col(:span="rightSpan" v-if="rightSpan")
        .formItem
          slot(name="rightSpan")
</template>
<script>
import AImage from '../Image'

export default {
  components: {
    AImage
  },
  props: {
    title: {
      type: String,
      default: ''
    },
    rightSpan: {
      type: Number,
      default: 0
    },
    items: {
      type: Array,
      default: () => {
        return []
      }
    },
    layoutCol: {
      type: Object,
      default: () => {
        return { sm: 12, md: 12, lg: 12 }
      }
    }
  },
  computed: {
    list () {
      return this.items.filter(x => !x.hidden)
    }
  }
}
</script>
<style lang="scss" scoped>
.formInfoBox{
  border-radius: 2px;
  overflow: hidden;
  border-top: 1px solid $--border-color-light;
  border-left: 1px solid $--border-color-light;

  .formItem{
    display: flex;

    .title, .content{
      border-right: 1px solid $--border-color-light;
      border-bottom: 1px solid $--border-color-light;
    }

    .title{
      font-size: 14px;
      color: $--color-text-primary;
      line-height: 1;
      padding: 18px 12px;
      background: #f5f7fa;
      text-align: right;

      > i {
        margin-right: 5px;
        vertical-align: middle;
      }
    }

    .content{
      font-size: 14px;
      color: $--color-text-regular;
      line-height: 1;
      padding: 18px 12px;
      flex: 1
    }

  }
}
</style>
